package com.console.operations.loanmgr;

import com.common.test.OperationBase;
import com.common.test.UITestBase;
import com.common.util.DBUtil;
import com.console.pages.loanmgr.LoanAuditPage;

public class LoanAudit extends OperationBase {
	
	public LoanAudit(UITestBase tb){
		super(tb);
	}
	
	//判断审核后理财计划债权状态是否为招标中
	public boolean isstatuscorrectedafteraudit = false;

	public void audit(String sequenceNo, String loanname) throws Exception{
		switchToDefaultContent();
		LoanAuditPage lap = new LoanAuditPage(tb);
		waitForElementExist(lap.sequenceinput);
		lap.sequenceinput.type(sequenceNo);
		log.info("sequenceNo is " + sequenceNo);
		lap.searchbutton.click();
		waitForPageContainsStr(loanname);
		lap.auditLnk.setfindValue("//tr[td[text()='"+ sequenceNo +"']]/td[a[text()='审核']]/a");
		lap.auditLnk.click();
		waitForElementExist(lap.auditpassbutton);
		movetoelement(lap.auditpassbutton);
		lap.auditpassbutton.click();
		waitForElementExist(lap.assurebutton);
		waitForElementDisplayed(lap.assurebutton);
		movetoelement(lap.assurebutton);
		lap.assurebutton.click();
		waitForPageContainsStr("审批通过");
		pause(1500);
		String status = DBUtil.queryOneCell("select dc_status\n"
										  + "from fiz_loan\n"
										  + "where vc_sequence = ?", new Object[]{sequenceNo});
		isstatuscorrectedafteraudit = status.equals("10");
		if(!isstatuscorrectedafteraudit){
			log.error("债权流水号[" + sequenceNo +"]状态不为招标中");
			return;
		}
	}
}
